﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class BaseData_TYLX : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Check.CheckPermission("200300104");
        if (!IsPostBack)
        {
            AspNetPager1.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["RowCountPerPage"].ToString());
            SearchControl1.InitParam("TYLX", "LXID", "TYPENAME", "TYLXListControl1", "rptTYLX", "AspNetPager1");
            Bind();
        }
    }
    private void Bind()
    {
        int pageCount, rowCount;
        List<Model.TYLX> properties = new BLL.TYLX().GetList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, "LXID", false, "", out pageCount, out rowCount);
        TYLXListControl1.Bind(properties);
        AspNetPager1.RecordCount = rowCount;
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        int pageCount, rowCount;
        if (SearchControl1.IsSearchResult)
        {
            Repeater rpt = (Repeater)TYLXListControl1.FindControl("rptTYLX");
            if (rpt != null)
            {
                string strSql;
                SearchControl1.BindParentPageControl(rpt, AspNetPager1, SearchControl1.DataTableName, SearchControl1.PrimaryKeyColumnName, SearchControl1.StrCondition, AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, out pageCount, out rowCount, out strSql);
            }
        }
        else
        {
            List<Model.TYLX> colors = new BLL.TYLX().GetList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, "LXID", false, "", out pageCount, out rowCount);
            TYLXListControl1.Bind(colors);
        }
    }
    public void Add()
    {
        if (true)//Check.CheckPermission("200300104", "00001")
        {
            Response.Redirect("TYLXEdit.aspx");
        }
        else
        {
            Share.Alert(this.Page, "无权操作"); return;
        }
    }
    public void Update()
    {
        if (true)//Check.CheckPermission("200300104", "00002")
        {
            List<int> s = TYLXListControl1.Selected;
            if (s.Count > 0)
            {
                Response.Redirect("TYLXEdit.aspx?code=" + s[0].ToString());
            }
            else
            {
                Page.RegisterStartupScript("StartUp", "<script language=javascript>alert('请选择一条需要编辑的记录')</script>");
            }
        }
        else
        {
            Share.Alert(this.Page, "无权操作"); return;
        }
    }
    public void Delete()
    {
        if (true)//Check.CheckPermission("200300104", "00003")
        {
            List<int> s = TYLXListControl1.Selected;
            new BLL.TYLX().Delete(s);
            //Share.InsertLog("200300104", "00003");
            Response.Redirect("AllProperty.aspx");
        }
        else
        {
            Share.Alert(this.Page, "无权操作"); return;
        }
    }
}
